Manipulate[

Module[{zoomScale,viewDomain,howBig, plotOpts,plotOptsType, paramSubst,funct,linef},

(* ImageSize of graph in pixels *)
howBig=200; 

(* Compute domain/range based on location of center and zoom settings *)
zoomScale[factor_]=(factor^3);
viewDomain[centerpt_,var_:0,radius_:zoomScale[zoomFactor]]:=If[NumberQ[var],{-Abs[radius]+centerpt,Abs[radius]+centerpt},
{var,
-Abs[radius]+centerpt,Abs[radius]+centerpt}];

(* Substitution rules for parameters used in user-entered equations *)
paramSubst={A->paramA,B->paramB,C->paramC};

(* Plot options common to all plots *)
plotOpts ={ImageSize->howBig};
plotOptsType=Options[Plot];

funct[u_]:=curve/.x->u/.paramSubst;

linef[x_,a_,b_]=(Piecewise[{{((funct[b]-funct[a])/(b-a))(x-a)+funct[a], b≠a}, {funct'[a](x-a)+funct[a], b==a}}]);

If[lineType=="Tangent",h=a];Column[{Quiet[Plot[Evaluate[{funct[x],linef[x,a[[1]],h[[1]]]}],Evaluate[viewDomain[viewPt[[1]],x]],PlotRange->Evaluate[viewDomain[viewPt[[2]]]],PlotStyle->{Red,Blue},AxesOrigin->{0,0},GridLines->Automatic,GridLinesStyle->Yellow,Epilog->{{PointSize[0.03],Red,Point[Evaluate[{a[[1]],funct[a[[1]]]}]]},{PointSize[0.03],Blue,Point[Evaluate[{h[[1]],funct[h[[1]]]}]]}}]],If[h≠a,Style[Row[{"Slope of secant: ",N[((funct[h[[1]]]-funct[a[[1]]])/(h[[1]]-a[[1]]))]}],"Subsubtitle",Blue,Small],Style[Row[{"Slope of tangent (at x=",N[a[[1]]],"): ",N[funct'[a[[1]]]]}],"Subsubtitle",Red,Small]]}]
],
Style["Secant and tangent lines. Drag the dots to change the points."],
{{curve,x Sin[x],"f[x] = "}},
{{a,{0,0}},{-20,0},{20,0},ControlType->Locator},{{h,If[lineType=="Secant",a+{2,0},a]},{-20,0},{20,0},ControlType->Locator,Appearance->None},{{lineType,"Secant","Line:"},{"Secant","Tangent"},ControlType->RadioButton},Style["Zoom"],
{{zoomFactor,1.7,""},6,0.1,ControlType->VerticalSlider,ControlPlacement->Left,ImageSize->Small},
{{viewPt,{0,0},""},{-20,-20},{20,20},ControlPlacement->Right,ImageSize->Small},
Delimiter,
{{paramA,1,"(+ integers) A"},0,50,1,Appearance->"Labeled",ControlPlacement->Bottom},
{{paramB,1,"(+/- integers) B"},-10,10,1,Appearance->"Labeled",ControlPlacement->Bottom},
{{paramC,0,"(+/- reals) C"},-1,1,Appearance->"Labeled",ControlPlacement->Bottom},Initialization:>(Off[General::obspkg];Off[General::newpkg];Import["http://www.austincc.edu/mmcguff/mathematica/gallery/RealOnly.m"])
]